![]() ![]() |
Q: I was "slumming" in toolbox land the other day and I
needed to use a progress indicator control (CDEF 5), along
with A: Support for 32-bit control values is implemented in the control definition, not in the Control Manager itself. If the control definition does not support 32-bit control values, values outside of the range -32768 through 32767 will be truncated using the following algorithm. This is probably not what you were looking for.
This raises a number of related questions: How can I tell whether a control definition supports 32-bit values? There is no general way of doing this. The only way to know whether it is safe to use 32-bit values with a particular control definition is to ask its author. Which standard control definitions support 32-bit values? In Mac OS 8.5 through 9.0, only the scroll bar (CDEFs 1 and 24) and slider (CDEF 3) control definitions support 32-bit values. How do I support 32-bit values in my control definition? The first step is to ensure that you call the 32-bit accessors when you need to access the control's value, minimum, and maximum. Obviously, you should do this only if these accessors are available (Mac OS 8.5 or later, or Carbon). Beyond that, it's a simple matter of checking that your implementation handles these large values. How do I work around this problem for the progress bar control? If the upper limit of your progress is beyond 32767, the simplest workaround is to set the control's maximum to 32767 and then scale the control value, as shown below. It is often convenient to use floating point arithmetic to avoid overflows. Isn't this supposed to be easier? Don't ask me, I'm just a networking guy. [2409633] [Nov 29 1999] |
Developer Documentation | Technical Notes | Development Kits | Sample Code |